/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package spring;

import java.awt.*;



/**
 *
 * @author spring
 */
public class PlotPanel2 extends javax.swing.JPanel{
    double[][] locMatrix = null;
    FeedAnalyzer FA;
    
    public PlotPanel2(){
    }
    
    public void setMatrix(double[][] M){
        locMatrix=M;
    }
    
    public void setAccess(FeedAnalyzer fa){
        FA=fa;
    }
    @Override
    public void paint(Graphics g){
       Dimension size = getSize();
         // TODO add your handling code here:
      super.paint(g);
      
      if (locMatrix == null){
      return;
      }
      
      int h = this.getHeight();
      int w = this.getWidth();
      int s = locMatrix.length;
      char[] NODES = new char[52];
      for (int i=0;i<26;i++) {
        NODES[i]=(char)(i+65);
        NODES[i+26]=(char)(i+97);
        }
    
       for (int j=0;j<s;j++){
           g.setColor(new java.awt.Color(0,0,0));
           g.fillOval((int)(locMatrix[j][0]*w-15), (int)(locMatrix[j][1]*h-12), 30, 30);
           g.setColor(new java.awt.Color(255,255,255));
           g.setFont(new java.awt.Font("Arial", java.awt.Font.BOLD, 25));
           g.drawChars(NODES, j%52, 1, 
                   (int)(locMatrix[j][0]*w)-10, (int)(locMatrix[j][1]*h)+10);
           g.setColor(new java.awt.Color(0,0,0));
           g.setFont(new java.awt.Font("Arial", java.awt.Font.BOLD, 13));
           FontMetrics fm = g.getFontMetrics();
            if (FA.feeds){
                g.drawString(FA.SFeed[j].getTitle(),
                        (int)(locMatrix[j][0]*w)-fm.stringWidth(FA.SFeed[j].getTitle())/2, 
                        (int)(locMatrix[j][1]*h)+25);
            } 
                    
            if (FA.entries){
                g.drawString(FA.EntryTitles[j], 
                        (int)(locMatrix[j][0]*w)-fm.stringWidth(FA.EntryTitles[j])/2, 
                        (int)(locMatrix[j][1]*h)+25);
            }
         }
    }

   
    
    
}
